use strict;

use lib '/var/www/perl/galleri';

use Galleri;
my $g = new Galleri();

my $user = $g->active_user;

my @albums = grep { $_->online and $user->level >= $_->default_level} Galleri::DB->resultset('Albums')->all;

if(@albums){
  
  my $h = join "", map { sprintf q{<li><a href="album.pl?album_id=%d">%s</a></li>},$_->id,$_->name } @albums;
  
  $g->add_content
    (
     subject => "Liste over fotoalbum",
     body => [ "<ul>" . $h . "</ul>" ],
    );
  
}
else{
  
  $g->add_content
    (
     subject => "Liste over fotoalbum",
     body => ["Ingen tilgjengelige album"],
    );
  
}

$g->output;

